package com.yun.util.yun.utils.file;

/**
 * @Author: niuduo
 * @Date: Create in 18:58 2018/8/13
 * @DESC:
 */
public class DocUtil {
    public static final String Lineseparator = "0x0D0A";
    public static final String Characterseparator = "0X1F";

    public DocUtil() {
    }

    public static String getLinesep() {
        String sbjline = "0x0D0A".substring(2, "0x0D0A".length());
        return hexStr2Str(sbjline);
    }

    public static String getCharactersepa() {
        String sbjline = "0X1F".substring(2, "0X1F".length());
        return hexStr2Str(sbjline);
    }

    public static String hexStr2Str(String hexStr) {
        String str = "0123456789ABCDEF";
        char[] hexs = hexStr.toCharArray();
        byte[] bytes = new byte[hexStr.length() / 2];

        for(int i = 0; i < bytes.length; ++i) {
            int n = str.indexOf(hexs[2 * i]) * 16;
            n += str.indexOf(hexs[2 * i + 1]);
            bytes[i] = (byte)(n & 255);
        }

        return new String(bytes);
    }
}
